<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" isELIgnored="false"%>
<%@ include file="/WEB-INF/common/head.jsp"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="UTF-8">
		<title>修改用户</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<link rel="stylesheet" href="${resource }/css/bootstrap.css" />
		<script type="text/javascript" src="${resource }/js/jquery-2.1.1.min.js"></script>
	</head>
	<body>
		<div class="row wrapper border-bottom white-bg page-heading">
			<div class="col-sm-4">
				<h2>用户管理</h2>
				<ol class="breadcrumb">
					<li>
						<a href="index.html">主页</a>
					</li>
					<li>
						<strong>添加用户</strong>
					</li>
				</ol>
			</div>
		</div>
		<div class="row wrapper border-bottom white-bg page-heading">
			<div class="col-md-12">
				<!-- 用户列表--bootstrap高级表格使用 -->
				<div class="panel panel-default">
					<div class="panel-heading">添加用户</div>
					<div class="panel-body">
						<form action="update.do" method="post">
							<input type="hidden" name="id" value="${user.id }" >
							<div class="form-group">
								<label for="txtAccount">账号</label> <input type="text" class="form-control" name="userAccount" placeholder="账号" value="${user.userAccount }"autocomplete="off">
							</div>
							<div class="form-group">
								<label for="txtUserName">姓名</label> <input type="text" class="form-control" name="userName" placeholder="姓名" value="${user.userName }"autocomplete="off">
							</div>
							<div class="form-group">
								<label for="txtUserRole">角色</label>
								 <select class="form-control" name="roleId" id="role">
									<c:forEach var="name"  items="${rlist}">
										<c:if test="${name.id==user.roleId}">
											<option value="${name.id}" selected>${name.roleName}</option>
										</c:if>
								    	<c:if test="${name.id!=user.roleId}">
											<option value="${name.id}" >${name.roleName}</option>
										</c:if>
								    </c:forEach>
								</select>
							</div>
							<div class="form-group">
								<label for="txtPhone">电话</label> <input type="text" class="form-control" name="userTel" placeholder="电话" value="${user.userTel }"autocomplete="off">
							</div>

							<div class="form-group">
								<label for="txtSex">部门</label>  
								<select class="form-control" name="departmentId" id="depart">
								<c:forEach var="name"  items="${dlist}">
									<c:if test="${name.id==user.departmentId}">
										<option value="${name.id}" selected>${name.deptName}</option>
									</c:if>
									<c:if test="${name.id!=user.departmentId}">
										<option value="${name.id}">${name.deptName}</option>
									</c:if>
								 </c:forEach>
								</select>
							</div>
							<div class="form-group">
								<label for="txtSex">状态</label>  
								<select class="form-control" name="userState" >
									<c:if test="${user.userState==1}">
										<option value="1" selected>可用</option>
										<option value="0">停用</option>
									</c:if>
									<c:if test="${user.userState==0}">
										<option value="1" >可用</option>
										<option value="0" selected>停用</option>
									</c:if>
								</select>
							</div>
							<button type="submit" class="btn btn-success" id="saveuser">保存</button>
							<button type="reset" class="btn btn-info">重置</button>
						</form>
					</div>
				</div>
			</div>
			<!--表格结束 -->
		</div>
			<script>
			 $(document).ready(function() {
			        var submit="update.do";
					$("form").submit(function(){
						var s=$("#role  option:selected");
						var d=$("#depart option:selected");
						if(d.text()!=s.text().slice(0,3))
						{  
							alert("部门与角色不匹配");
							return false;	
						}
						
					});
				}); 
			</script>
	</body>
</html>